<?php
	require_once PATH_OBJECT.'dataObject.php';
	
class dataObject_offre extends dataObject
{
 	
	/* @desc    Identifiant de l'offre
     * @var     int
     */
    public $_IDENTIFIANT_OFFRE = 0;
	
	
	/* @desc    Identifiant de l'offre
     * @var     int
     */
    public $_CODE_OFFRE = '';
	
	
	/* @desc    Identifiant de l'offre
     * @var     int
     */
    public $_LIBELLE_OFFRE = '';
	
	
	/* @desc    Identifiant de l'offre
     * @var     int
     */
    public $_DATE_DEBUT_OFFRE = '';
	
	
	/* @desc    Identifiant de l'offre
     * @var     int
     */
    public $_DATE_FIN_OFFRE = '';
	
    
	public function __construct( $iId=0 )
    {
       parent::__construct();

       if ( $iId != 0 )
       {
            $sQuery = "SELECT   *   /*+ dataObject_offre::__construct */  
                       FROM offre 
            		   WHERE Identifiant_offre = ".$iId." ORDER BY Libelle_offre";
            
            $aRows =  self::$_oConnexion->query($sQuery);
			$aRow = $aRows[0];
                 
			$this->_IDENTIFIANT_OFFRE = $iId;
			$this->_CODE_OFFRE = $aRow["Code_offre"];
			$this->_LIBELLE_OFFRE = $aRow["Libelle_offre"];
			$this->_DATE_DEBUT_OFFRE = self::showDate($aRow["Date_debut_offre"]);
			$this->_DATE_FIN_OFFRE = self::showDate($aRow["Date_fin_offre"]);
			
		
       }
    }
    /**
     * récupere la table offre selon le(s) criter(s) précisés ou pas 
	 */
    function offre_select( $sCritere = null )
    {
        $aRow = false;
    	$sQuery = "SELECT   *    
                   FROM offre 
            	   WHERE 1=1 
    				{$sCritere} ";
        $aRow =  self::$_oConnexion->query($sQuery);

        return $aRow;
    }
    
	public function offre_getListOffreOuvert( $sDateLimite)
    {
        $aRow = false;
    	$sCritere = " AND Date_debut_offre <= ".self::$_oConnexion->date($sDateLimite)."
    				 AND (Date_fin_offre is NULL 
    				     or Date_fin_offre >= ".self::$_oConnexion->date($sDateLimite).")";
        $aRow =  $this->offre_select ($sCritere);
        
        return $aRow;
    }
    
  	
}
?>